<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>封装一个兼容性的 addEvent方法</title>
</head>
<body>
<script>
    function addEvent(element,type,handle) {
        if(element.addEventListener){
            element.addEventListener(type,handle,false);
        }else if(element.attachEvent){
            element.attachEvent('on'+type,function () {
                handle.call(element);
            })
        }else {
            element['on'+type] = handle;
        }
    }
</script>
</body>
</html>
